package com.ymh.spring.learn.profile.config;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.jndi.JndiObjectFactoryBean;

/**
 * 
 * 名称：ProductionProfileConfig<br/>
 * 描述：用于生产环境的数据库连接池配置<br/>
 * 创建时间：2018年3月20日 下午5:18:38 <br/>
 * 
 * @author aivin
 * @version 1.0.0
 */
@Configuration
@Profile(value = "prod")
public class ProductionProfileConfig {

	@Bean
	public DataSource dataSource() {
		JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
		jndiObjectFactoryBean.setJndiName("jdbc/myDS");
		jndiObjectFactoryBean.setResourceRef(true);
		jndiObjectFactoryBean.setProxyInterface(DataSource.class);
		return (DataSource) jndiObjectFactoryBean.getObject();
	}

}
